package com.fit.dao.hotel;

import java.util.List;

import org.apache.tapestry5.hibernate.annotations.CommitAfter;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.hibernate.Session;

import com.fit.entities.Hotel;

public class HotelDAOImpl implements HotelDAO {

	@Inject
	private Session session;

	@CommitAfter
	public boolean save(Hotel hotel) {
		if (hotel != null) {
			session.save(hotel);
			return true;
		}
		return false;
	}

	public Hotel findById(Long id) {
		return (Hotel) session.get(Hotel.class, id);
	}

	public List<Hotel> findAll() {
		return session.createCriteria(Hotel.class).list();
	}

}
